﻿//  Copyright (c) 2011 Ray Liang (http://www.dotnetage.com)
//  Licensed MIT: http://www.opensource.org/licenses/mit-license.php

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DNA.Mvc
{
    /// <summary>
    /// Present the base class to process the Event which name has been matched.
    /// </summary>
    public abstract class EventNamebaseObserver : EventObserver
    {
        /// <summary>
        /// Gets/Sets which event should be processed.
        /// </summary>
        public virtual string EventName { get; set; }

        /// <summary>
        /// Process event.
        /// </summary>
        /// <param name="value"></param>
        public abstract void Process(EventBase value);

        protected override void ProcessEvent(EventBase value)
        {
            if (value.Name.Equals(EventName, StringComparison.OrdinalIgnoreCase))
                Process(value);
        }
    }
}
